// 获取桶/管颜色
import { spinTubeColorPage } from '../../../../../../api/basicData/tubeColor';

export default {
	props: {

	},
	data() {
		return {
			inputTubeColorList: [],
			outTubeColorList: [],

			smColorList: [],
			btColorList: [],
			csColorList: [],
			xsColorList: [],
			ltColorList: []
		};
	},
	methods: {
		getColorInfoByProcess(processCode) {
			const code = processCode ? processCode.toUpperCase() : '';
			let item = {};
			switch (code) {
				case 'BN':
					item = {
						inputName: '并线管色',
						outName: '倍捻管色',
						inputTypeCode: 'BX_TUBE_COLOR',
						outTypeCode: 'BN_TUBE_COLOR'
					};
					break;
				case 'BX':
					item = {
						inputName: '纸管颜色',
						outName: '并线管色',
						inputTypeCode: 'LT_TUBE_COLOR',
						outTypeCode: 'BX_TUBE_COLOR'
					};
					break;
				case 'LT':
					item = {
						inputName: '细纱管颜色',
						outName: '纸管颜色',
						inputTypeCode: 'XS_TUBE_COLOR',
						outTypeCode: 'LT_TUBE_COLOR'
					};
					break;
				case 'XS':
					item = {
						inputName: '粗纱管颜色',
						outName: '细纱管颜色',
						inputTypeCode: 'CS_TUBE_COLOR',
						outTypeCode: 'XS_TUBE_COLOR'
					};
					break;
				case 'CS':
					item = {
						inputName: '熟条桶圈颜色',
						outName: '粗纱管颜色',
						inputTypeCode: 'BT_TUBE_COLOR',
						outTypeCode: 'CS_TUBE_COLOR'
					};
					break;
				case 'BT':
					item = {
						inputName: '生条桶圈颜色',
						outName: '熟条桶圈颜色',
						inputTypeCode: 'SM_TUBE_COLOR',
						outTypeCode: 'BT_TUBE_COLOR'
					};
					break;
				case 'TB':
					item = {
						inputName: '生条桶圈颜色',
						outName: '半熟条桶圈颜色',
						inputTypeCode: 'SM_TUBE_COLOR',
						outTypeCode: 'TB_TUBE_COLOR'
					};
					break;
				case 'EB':
					item = {
						inputName: '半熟条桶圈颜色',
						outName: '熟条桶圈颜色',
						inputTypeCode: 'TB_TUBE_COLOR',
						outTypeCode: 'EB_TUBE_COLOR'
					};
					break;
				case 'SM':
					item = {
						inputName: '配棉方案',
						outName: '生条桶圈颜色',
						inputTypeCode: '',
						outTypeCode: 'SM_TUBE_COLOR'
					};
					break;
				default: item = {};
			}
			return item;
		},
		// 输入颜色
		getInputColorListRequest(typeCode) {
			return spinTubeColorPage({ typeCode }).then(res => {
				if (res.data.status === 200) {
					this.inputTubeColorList = res.data.res ? res.data.res.map(x => {
						return {
							id: x.id,
							name: x.name
						};
					}) : [];
				}
			});
		},
		// 输出颜色
		getOutColorListRequest(typeCode) {
			return spinTubeColorPage({ typeCode }).then(res => {
				if (res.data.status === 200) {
					this.outTubeColorList = res.data.res ? res.data.res.map(x => {
						return {
							id: x.id,
							name: x.name
						};
					}) : [];
				}
			});
		},
		// 梳棉桶圈颜色
		getSmColorListRequest() {
			return spinTubeColorPage({ typeCode: 'SM_TUBE_COLOR' }).then(res => {
				if (res.data.status === 200) {
					this.smColorList = res.data.res ? res.data.res.map(x => {
						return {
							id: x.id,
							name: x.name
						};
					}) : [];
				}
			});
		},
		// 并条桶圈颜色
		getBtColorListRequest() {
			return spinTubeColorPage({ typeCode: 'BT_TUBE_COLOR' }).then(res => {
				if (res.data.status === 200) {
					this.btColorList = res.data.res ? res.data.res.map(x => {
						return {
							id: x.id,
							name: x.name
						};
					}) : [];
				}
			});
		},
		// 粗纱管颜色(粗纱)
		getCsColorListRequest() {
			return spinTubeColorPage({ typeCode: 'CS_TUBE_COLOR' }).then(res => {
				if (res.data.status === 200) {
					this.csColorList = res.data.res ? res.data.res.map(x => {
						return {
							id: x.id,
							name: x.name
						};
					}) : [];
				}
			});
		},
		// 细纱管颜色(细纱)
		getXsColorListRequest() {
			return spinTubeColorPage({ typeCode: 'XS_TUBE_COLOR' }).then(res => {
				if (res.data.status === 200) {
					this.xsColorList = res.data.res ? res.data.res.map(x => {
						return {
							id: x.id,
							name: x.name
						};
					}) : [];
				}
			});
		},
		// 纸管颜色(络筒)
		getLtColorListRequest() {
			return spinTubeColorPage({ typeCode: 'TUBE_COLOR' }).then(res => {
				if (res.data.status === 200) {
					this.ltColorList = res.data.res ? res.data.res.map(x => {
						return {
							id: x.id,
							name: x.name
						};
					}) : [];
				}
			});
		}
	}
};
